package com.cuit.service.Impl;

import com.cuit.dao.PatientDao;
import com.cuit.dao.impl.PatientDaoImpl;
import com.cuit.pojo.AcceptOrderData;
import com.cuit.pojo.Doctor;
import com.cuit.pojo.DoctorOrder;
import com.cuit.pojo.Patient;
import com.cuit.service.PatientService;

import java.util.List;

public class PatientServiceImpl implements PatientService {
    PatientDao patientDao = new PatientDaoImpl();

    @Override
    public void register(Patient patient) {
        patientDao.save(patient);
    }

    @Override
    public Patient login(Patient patient) {
        return patientDao.queryByIdAndPassword(patient.getP_id(), patient.getP_password());
    }

    @Override
    public void modifyPassword(String p_id, String p_password) {
       patientDao.modifyPassword(p_id,p_password);
    }

    @Override
    public void modify(Patient patient) {
        patientDao.modify(patient);
    }

    @Override
    public List<AcceptOrderData> queryDoctor(Doctor doctor, DoctorOrder doctorOrder) {
        return patientDao.queryDoctor(doctor.getName(),doctor.getDepartment(),doctor.getGrade(),doctorOrder.getD_sitting_time(),doctorOrder.getMax_order(),doctorOrder.getD_week());
    }

    @Override
    public boolean existPatient(String p_id) {
        if (patientDao.queryById(p_id) == null) {
            return false;   //手机号不存在，可以使用
        } else {
            return true;
        }
    }
}
